<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../react18/react.development.js"></script>
    <script src="../../react18/react-dom.development.js"></script>
    <script src="../../react18/babel.min.js"></script>
    <script src="../../react18/prop-types.js"></script>
</head>

<body>
    <div id="app"> </div>
    <script type="text/babel">
        /*
    字符串形式的Refs:
      - 给被获取的元素添加一个ref属性,值是字符串(随意命名)
      - 在组件实例上就会有一个ref对象,对象中有一个你设置的字符串属性,值是他代表的DOM
  */
  //y：创建组件实例的时候首字母为大写
        class GetIptValue extends React.Component{
            render(){
               return (<div>
                    <input type="text"ref='inp'/>
                    <button onClick={this.handle} >submit</button>
                    </div>)
            }
            handle=()=>{
                const {inp}=this.refs
                console.log(inp.value);
            }
        }
        const root=ReactDOM.createRoot(document.getElementById('app'))
        root.render(<GetIptValue/>)
        </script>
</body>

</html>